class TagsController < ApplicationController

  before_filter :login_required
  
  def personas
    store_location
    @tag = params[:tag]
    @personas = Persona.find_tagged_with(@tag)
  end

  def nube
    store_location
    @tags = Persona.tag_counts
  end

  # le agrega los tags recibidos a la persona ID
  def tag
    @persona = Persona.find(params[:id])
    @persona.tag_list.add(params[:tags], :parse=>true)
    @persona.save
    render :partial=>'tags'
  end

  # elimina los tags recibidos de la persona ID
  def untag
    @persona = Persona.find(params[:id])
    @persona.tag_list.remove(params[:tag])
    @persona.save
    render :partial=>'tags'
  end

  def destroy
    Tag.find(params[:id]).destroy
    redirect_to :controller=>'tags', :action=>'nube'
  end
  
end
